import 'package:example/generated/json/base/json_convert_content.dart';
import 'package:example/models/todo_entity.dart';

TodoEntity $TodoEntityFromJson(Map<String, dynamic> json) {
  final TodoEntity todoEntity = TodoEntity();
  final int? completeDate = jsonConvert.convert<int>(json['completeDate']);
  if (completeDate != null) {
    todoEntity.completeDate = completeDate;
  }
  final String? completeDateStr = jsonConvert.convert<String>(
      json['completeDateStr']);
  if (completeDateStr != null) {
    todoEntity.completeDateStr = completeDateStr;
  }
  final String? content = jsonConvert.convert<String>(json['content']);
  if (content != null) {
    todoEntity.content = content;
  }
  final int? date = jsonConvert.convert<int>(json['date']);
  if (date != null) {
    todoEntity.date = date;
  }
  final String? dateStr = jsonConvert.convert<String>(json['dateStr']);
  if (dateStr != null) {
    todoEntity.dateStr = dateStr;
  }
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    todoEntity.id = id;
  }
  final int? priority = jsonConvert.convert<int>(json['priority']);
  if (priority != null) {
    todoEntity.priority = priority;
  }
  final int? status = jsonConvert.convert<int>(json['status']);
  if (status != null) {
    todoEntity.status = status;
  }
  final String? title = jsonConvert.convert<String>(json['title']);
  if (title != null) {
    todoEntity.title = title;
  }
  final int? type = jsonConvert.convert<int>(json['type']);
  if (type != null) {
    todoEntity.type = type;
  }
  final int? userId = jsonConvert.convert<int>(json['userId']);
  if (userId != null) {
    todoEntity.userId = userId;
  }
  return todoEntity;
}

Map<String, dynamic> $TodoEntityToJson(TodoEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['completeDate'] = entity.completeDate;
  data['completeDateStr'] = entity.completeDateStr;
  data['content'] = entity.content;
  data['date'] = entity.date;
  data['dateStr'] = entity.dateStr;
  data['id'] = entity.id;
  data['priority'] = entity.priority;
  data['status'] = entity.status;
  data['title'] = entity.title;
  data['type'] = entity.type;
  data['userId'] = entity.userId;
  return data;
}

extension TodoEntityExtension on TodoEntity {
  TodoEntity copyWith({
    int? completeDate,
    String? completeDateStr,
    String? content,
    int? date,
    String? dateStr,
    int? id,
    int? priority,
    int? status,
    String? title,
    int? type,
    int? userId,
  }) {
    return TodoEntity()
      ..completeDate = completeDate ?? this.completeDate
      ..completeDateStr = completeDateStr ?? this.completeDateStr
      ..content = content ?? this.content
      ..date = date ?? this.date
      ..dateStr = dateStr ?? this.dateStr
      ..id = id ?? this.id
      ..priority = priority ?? this.priority
      ..status = status ?? this.status
      ..title = title ?? this.title
      ..type = type ?? this.type
      ..userId = userId ?? this.userId;
  }
}